Skip to content

Add Edit Network Interface Modal#985

Merged
just-be-dev merged 8 commits into
mainfrom
add-network-edit
Jun 29, 2022
Merged

Add Edit Network Interface Modal#985
just-be-dev merged 8 commits into
mainfrom
add-network-edit

Conversation

@just-be-dev

@just-be-dev just-be-dev commented Jun 28, 2022

Copy link
Copy Markdown
Contributor

Fixes #933

Changes

  • Updated the NIC table to show which is primary

image

  • Added edit form

image

It's notable that Primary is disabled if the NIC you're editing is already primary. @benjaminleonard this could probably use a better design. Should I put a field title over it?

TODO

  • Add E2E tests
  • Add tooltip to primary checkbox and make the UI not suck

@vercel

vercel Bot commented Jun 28, 2022

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
console-ui-storybook ✅ Ready (Inspect) Visit Preview Jun 28, 2022 at 8:43PM (UTC)

@benjaminleonard

benjaminleonard commented Jun 28, 2022

Copy link
Copy Markdown
Contributor

Yeah we should include a field title, a description, and a tooltip
I'm also wondering if we should use a radio button for this. I think I'll mock something up, because it's probably useful to see the consequences of your selection...i.e. if this becomes the primary NIC the other/s becomes....I don't know.

Primary also implies an order. If you had three NICs, are two of them secondary?

Also worth saying we don't currently have a disabled state for a selected checkbox. I'm thinking of using opacity for disabled states instead of the fixed colours.

Edit: The idea of disabling it because its already primary feels unusual to me, and editing other NICs within another NIC's pane also. Since to make one primary, you would need to demote another.

Perhaps better suited for a modal action outside of the pane, as in a button that is "Set Primary NIC", with radio buttons or a dropdown.

@benjaminleonard

benjaminleonard commented Jun 28, 2022

Copy link
Copy Markdown
Contributor

and it goes a lil' something like this (ignore that it's selecting the current selected item)
CleanShot 2022-06-28 at 11 16 33

with edit pane - not sure what we call the 'Primary' field. How is this reflected in the API? A boolean?
image

@bnaecker

bnaecker commented Jun 28, 2022 via email

Copy link
Copy Markdown
Contributor

@just-be-dev

Copy link
Copy Markdown
Contributor Author

@benjaminleonard, primary is a Boolean, yes.

@benjaminleonard

Copy link
Copy Markdown
Contributor

@benjaminleonard, primary is a Boolean, yes.

Cool – I ask because the column name is Primary, I like to have text not just the checkmark icon so we're not relying entirely on the icon for meaning. Not that it's particularly ambiguous.

So currently it says Primary: Primary. Idk if there's a better way of doing that, it's probably fine for now.

@just-be-dev

Copy link
Copy Markdown
Contributor Author

Oh, also, we can't change the ip address either. It's only the name and description that are editable.

@just-be-dev

Copy link
Copy Markdown
Contributor Author

I've added the action to make a NIC primary in the row actions menu. I'll create an issue to do a follow up. The are questions around the modal approach like what columns besides name would be needed in the modal to make the decision to switch which is primary. We also need to figure out how to manage what's the primary interface on instance create when making a custom NIC.

image

@just-be-dev just-be-dev marked this pull request as ready for review June 28, 2022 19:49
@bnaecker

Copy link
Copy Markdown
Contributor

We also need to figure out how to manage what's the primary interface on instance create when making a custom NIC.

The primary NIC is always the first one, if multiple are specified at instance-creation time. Really, the first interface to be attached to an instance is the primary, no matter when they're specified (instance create, or later with new requests to add a NIC to an instance).

@just-be-dev

Copy link
Copy Markdown
Contributor Author

I updated the UI of the table itself to be closer to the storage tab (complete with text that says editing can only happen when the instance is stopped)

image

// Close toast, it holds up the test for some reason
await page.click('role=button[name="Dismiss notification"]')
await expectNotVisible(page, ['role=cell[name="nic-2"]'])
await expectNotVisible(page, ['role=cell[name="nic-3"]'])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love all this

</div>
<h2 id="network-interfaces" className="mb-4 text-mono-sm text-secondary">
Network Interfaces
</h2>

@david-crespo david-crespo Jun 28, 2022

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches what's on storage, and I agree we need something to say what's in the table, but I think it's too small (which probably means the disks ones are too small too?) @benjaminleonard

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave that for a polish follow up

Comment thread app/util/e2e.ts
const text = cellTexts[i]
if (text === null) {
continue
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good change

invariant(
instanceName,
'instanceName is required when posting a network interface'
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you anticipate using this form in a context where we don't have an instanceName? Otherwise this is basically the same as including 'instanceName' in the useParams() on line 21.

I also don't see why we need an invariant on interfaceName since it's a required field in the form — the invariant is enforced by form validation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's used in the instance-create-form (via the custom NIC option) then instanceName wouldn't be in the path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for the invariant on interfaceName... this is mostly b/c the PUT method doesn't require any of these inputs. We use NetworkInterfaceUpdate to drive initialValues which has name typed as string | null | undefined. The modal is invoked like below, notice that initialValues is potentially an empty object.

      <EditNetworkInterfaceSideModalForm
        isOpen={!!editing}
        initialValues={editing || {}}
        onDismiss={() => setEditing(null)}
      />

@david-crespo

david-crespo commented Jun 28, 2022

Copy link
Copy Markdown
Collaborator

Edit: this is unrelated to this PR, made it its own issue #993


These lines in the mock NIC create endpoint (which were already there) mean that any NIC create without a VPC name and a subnet name will 404.

const [vpc, vpcErr] = lookupVpc({ ...req.params, vpcName: vpc_name })
if (vpcErr) return res(vpcErr)
const [subnet, subnetErr] = lookupVpcSubnet({
...req.params,
vpcName: vpc_name,
subnetName: subnet_name,
})
if (subnetErr) return res(subnetErr)

Turns out these are not actually optional on the POST, which is a relief because I did not understand how that would work. So those fields should be marked required in the create form.

https://github.com/oxidecomputer/omicron/blob/a0e5d59a3190b40138c5d6928f6cb89aebb00e9b/nexus/src/external_api/params.rs#L275-L287

@just-be-dev

Copy link
Copy Markdown
Contributor Author

I'm going to merge to move forward, but again I have #991 for updates. If anything else comes up in post review, let me know and I'll add it to that issue as a follow up.

@just-be-dev just-be-dev merged commit 540d9d4 into main Jun 29, 2022
@just-be-dev just-be-dev deleted the add-network-edit branch June 29, 2022 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update network interfaces

4 participants